package com.fire.control.system.config.interceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.fire.control.system.support.util.StaticValue;

@Configuration
public class MyWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {
	
	private static final Logger logger = LoggerFactory.getLogger(MyWebMvcConfigurerAdapter.class);
	
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //多个拦截器组成一个拦截器链
        //addPathPatterns 用于添加拦截规则(支持模糊匹配)
        //excludePathPatterns 用于排除拦截(不支持模糊匹配)
    	
    	registry.addInterceptor(new WebInterceptor()).addPathPatterns("/web/**");
    	
        registry.addInterceptor(new AppInterceptor()).addPathPatterns("/app/**");
        
        super.addInterceptors(registry);
    }
    
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
    	/**
    	# 默认值为 /**
		spring.mvc.static-path-pattern=
		# 默认值为 classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/ 
		spring.resources.static-locations=这里设置要指向的路径，多个使用英文逗号隔开
    	 */
    	registry.addResourceHandler("/**").addResourceLocations("classpath:/static/").addResourceLocations("file:"+StaticValue.file_upload_path).addResourceLocations("file:"+StaticValue.lora_view_path);
    	
    	super.addResourceHandlers(registry);
    }

}